﻿//创建时间: 2010-12-10
//创建作者: 李 城
//功能说明: 评论列表
//最后修改: 2010-12-10
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;

using System.Data;
using System.Text;
using System.Collections;
using Newtonsoft.Json;

namespace TRPOP.CMS.Web.Admin
{
    public partial class Recomment_list : BaseAdmin
    {

        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_strPagePermissionExtraKey = "Plugin_comment";
        }
        #endregion

        #region 页面变量
        protected string m_title = "评论列表";
        protected int intNodeid = 0;
        protected int intContentID = 0;
        protected int m_intRecordCount = 0;
        protected RecomManage mRecomManage = new RecomManage();
        protected RecomContentManage mRecomContentManage = new RecomContentManage();
        protected string m_ConfigTypeKey = "Recomment";
        #endregion

        #region 页面事件

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int.TryParse(InitRequestViewState("nodeid"), out intNodeid);
                int.TryParse(InitRequestViewState("id"), out intContentID);
                if (intNodeid > 0)//验证用户是否有权限操作当前结点
                    base.AlertForNoPermission(base.CheckIsHavePermission(intNodeid));
                if (intContentID > 0)
                {
                    txtContentid.Text = intContentID.ToString();
                }
                LoadBase();
            }
            LoadData();
        }

        protected void LoadData()
        {
            int.TryParse(GetRequestViewState("nodeid"), out intNodeid);
            NodeInfo oNodeInfo = new NodeManage().GetInfoById(intNodeid);
            if (oNodeInfo != null)
                m_title += " -> " + oNodeInfo.Name;
            else
                m_title += " -> 所有评论";
        }

        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            LinkButton lbtn = (LinkButton)sender;
            int intRecid = 0;
            int.TryParse(lbtn.CommandArgument, out intRecid);
            mRecomContentManage.DeleteInfoById(intRecid);
            SubmitAlertDelete(mRecomManage.DeleteInfoById(intRecid));
            base.SaveLog(Plugin.LogKeys.OperObject.PluginOper, Plugin.LogKeys.OperResult.DelSubmit, m_ConfigTypeKey+":"+intRecid);
            LoadBase();
            Pager.Page_ReLoad();
        }
        protected void btSearch_Click(object sender, EventArgs e)
        {
            LoadBase();
            Pager.Page_ReLoad();
        }        
        #endregion

        #region 页面方法
        public void LoadBase()
        {
            int.TryParse(GetRequestViewState("nodeid"), out intNodeid);
            if (Pager.PageSize <= 0) { Pager.PageSize = SYSConfig.SystemVar_AdminContentPageNum; }
            string strNodeIdsCondation = base.m_IAdminUser.GetEnabledNodeIds();
            //这里加上了结点
            if (strNodeIdsCondation == "all" || strNodeIdsCondation.IsEmpty())
                rptList.DataSource = mRecomManage.GetRecommentDT(intNodeid, Pager.CurrentPage, Pager.PageSize, out m_intRecordCount, txtContentid.Text.Trim().ToInt(), txtAddTimeBegin.Text.Trim().ToDateTime(), txtAddTimeEnd.Text.Trim().ToDateTime());
            else
                rptList.DataSource = mRecomManage.GetRecommentDT(intNodeid, Pager.CurrentPage, Pager.PageSize, out m_intRecordCount, txtContentid.Text.Trim().ToInt(), txtAddTimeBegin.Text.Trim().ToDateTime(), txtAddTimeEnd.Text.Trim().ToDateTime(), strNodeIdsCondation);
            Pager.ShowRecordCount = true;
            Pager.ShowPageSize = true;
            Pager.ShowCurrentPage = true;
            Pager.RecordCount = m_intRecordCount;
            rptList.DataBind();
        }
        #endregion

    }
}
